package com.bruan.exception;

public class ExceptionTest2 {
    public static void main(String[] args) {
        try {
            saveAge(150);
            System.out.println("底层执行成功");
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("底层出现bug");
        }
    }

    public static void saveAge(int age){
        if (age>0&&age<150){
            System.out.println("年龄被成功保存"+age);
        }else {
            //用异常对象封装并且抛出
            throw new AgeIllegalRuntimeException("/age is illegal,your age is"+age);
        }
    }

}

